class RMCamera extends Camera;

var vector LazyLocation;
var rotator LazyRotation;
var int LocationLaziness, RotationLaziness;
var float AimLocationLaziness, AimRotationLaziness;
var float TransitionInterval;
var vector TransitionOffset;
var float CameraRoll;
var vector	CoverOffset;
var RMPawn cameraTarget;
var float cameraDistance;

var rotator RotationModifier;
var rotator MaxRotationModifier;
var float LastKickTime;

var float Forward, Strafe, Up;

var vector VeryLazyCamOffset, LazyCamOffset, AimCamOffset;

// Let's the camera know how the player is moving so it can simulate camera bobbing and similar stuff.
simulated function SetInputs(float InForward, float InStrafe, float InUp)
{
	Forward = InForward / 2000.0f;
	Strafe = InStrafe / 2000.0f;
	CoverOffset = FreeCamOffset; //used in else if statement below for modifying camera angles during cover
	Up = InUp;
}

// renders the third person camera location

function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
{
	local Rotator myRotation;
	local Vector origin, myLocation;
	local float rotationPercentage, panningPercentage;

	//grab the player
	cameraTarget = RMPawn(PCOwner.Pawn);

	//now that the player has spawned
	if(cameraTarget != none)
	{
		//follow player if moving
		if(cameraTarget.bIsMoving)
		{
			//camera's freedom
			rotationPercentage = 0.15;
			panningPercentage = 0.6;

			//adjust rotation
			myRotation.Pitch = cameraTarget.Rotation.Pitch * rotationPercentage;
			myRotation.Yaw = cameraTarget.Rotation.Yaw * rotationPercentage;

			//adjust location
			origin = cameraTarget.Location;
			myLocation.Y = (cameraTarget.Location.Y - origin.Y)* panningPercentage + origin.Y;
			myLocation.Z = (cameraTarget.Location.Z - origin.Z)* panningPercentage + origin.Z;
			myLocation.X = cameraTarget.Location.X - cameraDistance*5;
		}

		//else watch player die
		else
		{
			myRotation = Rotator(cameraTarget.Location - myLocation);
		}

		//Output values
		OutVT.POV.Rotation = myRotation;
		OutVT.POV.Location = myLocation;
	}
}

defaultproperties
{
	LazyLocation = (X=0,Y=0,Z=0)
	cameraDistance = 30.0
	RotationModifier = (Pitch=0,Yaw=0,Roll=0)
	VeryLazyCamOffset=(X=-192.0,Y=0.0,Z=80.0)
	LazyCamOffset=(X=-82.0,Y=20.0,Z=64.0)
	AimCamOffset=(X=-48.0,Y=32.0,Z=48.0)
	LocationLaziness=10
	RotationLaziness=8
	TransitionInterval=0.2
	CameraRoll=384.0
	MaxRotationModifier=(Pitch=16384,Yaw=2048,Roll=512)
}